#include "Mario.h"

 Mario::Mario() 
{
     this->RestartTheGame();
}

 void Mario::RestartTheGame()
 {
     std::cout << "Game Start!!!!! " << std::endl;
     this->coin = 0;
     this->lastcoin = 0;
     this->life = 3;
     this->state = &SmallMario::GetInstance();
 }

 void Mario::RestartTheLife()
 {
     std::cout << "Retry this life " << std::endl;
     this->coin = this->lastcoin;
     this->state = &SmallMario::GetInstance();
 }

 void Mario::Retry()
 {
     std::cout << "Retry next life" << std::endl;
     this->life=this->life-1;
     this->state = &SmallMario::GetInstance();
 }

 void Mario::SetState(IState* state)
 {
    this->state = state;
}

 void Mario::SetCoin(int numberOfCoins) 
 {
    std::cout << "Got Coins: " << numberOfCoins << std::endl;
    this->coin += numberOfCoins;
    if (coin<0)
        coin = 0;
}

 void Mario::ReportCoin() const
 {
    std::cout << "Total Coin: " << coin << std::endl;
}

 void Mario::GotMushroom() 
 {
    this->state->GotMushroom(this);
}

 void Mario::GotFireFlower() 
 {
    this->state->GotFireFlower(this);
}

 void Mario::GotFeather()
 {
     this->state->GotFeather(this);
 }

 void Mario::GotMonster()
 {
     this->state->GotMonster(this);
 }

 void Mario::GotCoin( )
 {
     this->state->GotCoin(this);
 }

 void Mario::GotDie()
 {
     if (this->life-1==0) {
         std::cout << "Game Over " << std::endl;
         this->RestartTheGame();
         return;
     }
     else{
         std::cout << "You Are Die " << std::endl;
         std::cout << "Left " << this->life - 1 << " life" << std::endl;
         this->Retry();
         return;
     }
 }

 void Mario::GotFall()
 {
    this->GotDie();
 }

 void Mario::Pass()
 {
     std::cout << "congratulations !!!" << std::endl;
     std::cout << "Lifes increase" << std::endl;
     this->lastcoin = this->coin;
     this->life++;
 }
